﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RankItem : MonoBehaviour
{
    /// <summary>
    /// 榜单列表   1是财富榜    2是赚金榜
    /// </summary>
    public int ListType;
    /// <summary>
    /// 排名图标
    /// </summary>
    public UISprite RankSprite;
    /// <summary>
    /// 头像
    /// </summary>
    public UISprite Icon;
    /// <summary>
    /// 昵称
    /// </summary>
    public UILabel NickName;
    /// <summary>
    /// 金币数量
    /// </summary>
    public UILabel Num;
    /// <summary>
    /// 排行
    /// </summary>
    public int Rank;
    /// <summary>
    /// 头像ID，昵称，金币数量，榜单种类，排行
    /// </summary>
    /// <param name="iconId"></param>
    /// <param name="nickName"></param>
    /// <param name="num"></param>
    public void Set(int iconId, string nickName, string num, int list, int rank)
    {
        rank += 1;
        // 设置头像
        Icon.spriteName = iconId.ToString();
        // 设置昵称
        NickName.text = nickName;
        // 设置金币数量
        Num.text = num;
        // 设置排名图标
        if (rank <= 3)
        {
            // 财富榜
            if (list == 1)
            {
                RankSprite.spriteName = "crown_" + rank;
            }
            // 赚金榜
            else if (list == 2)
            {
                RankSprite.spriteName = rank.ToString();
            }
        }
        else
        {

            RankSprite.spriteName = rank.ToString();
            RankSprite.width = RankSprite.GetAtlasSprite().width;
            RankSprite.height = RankSprite.GetAtlasSprite().height;
        }

    }
}
